3.1201 \(\int \frac{(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx\)

Optimal. Leaf size=126 \[ -\frac{(b c-a d)^2}{b f \left (a^2+b^2\right ) (a+b \tan (e+f x))}+\frac{2 (a c+b d) (b c-a d) \log (a \cos (e+f x)+b \sin (e+f x))}{f \left (a^2+b^2\right )^2}-\frac{x (b (c-d)-a (c+d)) (a (c-d)+b (c+d))}{\left (a^2+b^2\right )^2} \]

[Out]

-(((b*(c - d) - a*(c + d))*(a*(c - d) + b*(c + d))*x)/(a^2 + b^2)^2) + (2*(b*c - a*d)*(a*c + b*d)*Log[a*Cos[e
+ f*x] + b*Sin[e + f*x]])/((a^2 + b^2)^2*f) - (b*c - a*d)^2/(b*(a^2 + b^2)*f*(a + b*Tan[e + f*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.231562, antiderivative size = 126, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 25, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.12, Rules used = {3542, 3531, 3530} \[ -\frac{(b c-a d)^2}{b f \left (a^2+b^2\right ) (a+b \tan (e+f x))}+\frac{2 (a c+b d) (b c-a d) \log (a \cos (e+f x)+b \sin (e+f x))}{f \left (a^2+b^2\right )^2}-\frac{x (b (c-d)-a (c+d)) (a (c-d)+b (c+d))}{\left (a^2+b^2\right )^2} \]

Antiderivative was successfully verified.

[In]

Int[(c + d*Tan[e + f*x])^2/(a + b*Tan[e + f*x])^2,x]

[Out]

-(((b*(c - d) - a*(c + d))*(a*(c - d) + b*(c + d))*x)/(a^2 + b^2)^2) + (2*(b*c - a*d)*(a*c + b*d)*Log[a*Cos[e
+ f*x] + b*Sin[e + f*x]])/((a^2 + b^2)^2*f) - (b*c - a*d)^2/(b*(a^2 + b^2)*f*(a + b*Tan[e + f*x]))

Rule 3542

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> Simp[
((b*c - a*d)^2*(a + b*Tan[e + f*x])^(m + 1))/(b*f*(m + 1)*(a^2 + b^2)), x] + Dist[1/(a^2 + b^2), Int[(a + b*Ta
n[e + f*x])^(m + 1)*Simp[a*c^2 + 2*b*c*d - a*d^2 - (b*c^2 - 2*a*c*d - b*d^2)*Tan[e + f*x], x], x], x] /; FreeQ
[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && LtQ[m, -1] && NeQ[a^2 + b^2, 0]

Rule 3531

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[((a*c +
 b*d)*x)/(a^2 + b^2), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3530

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c*Log[Re
moveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]])/(b*f), x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rubi steps

\begin{align*} \int \frac{(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx &=-\frac{(b c-a d)^2}{b \left (a^2+b^2\right ) f (a+b \tan (e+f x))}+\frac{\int \frac{2 b c d+a \left (c^2-d^2\right )+\left (2 a c d-b \left (c^2-d^2\right )\right ) \tan (e+f x)}{a+b \tan (e+f x)} \, dx}{a^2+b^2}\\ &=-\frac{(b (c-d)-a (c+d)) (a (c-d)+b (c+d)) x}{\left (a^2+b^2\right )^2}-\frac{(b c-a d)^2}{b \left (a^2+b^2\right ) f (a+b \tan (e+f x))}+\frac{(2 (b c-a d) (a c+b d)) \int \frac{b-a \tan (e+f x)}{a+b \tan (e+f x)} \, dx}{\left (a^2+b^2\right )^2}\\ &=-\frac{(b (c-d)-a (c+d)) (a (c-d)+b (c+d)) x}{\left (a^2+b^2\right )^2}+\frac{2 (b c-a d) (a c+b d) \log (a \cos (e+f x)+b \sin (e+f x))}{\left (a^2+b^2\right )^2 f}-\frac{(b c-a d)^2}{b \left (a^2+b^2\right ) f (a+b \tan (e+f x))}\\ \end{align*}

Mathematica [C]  time = 1.92652, size = 321, normalized size = 2.55 \[ \frac{(c+d \tan (e+f x))^2 (a \cos (e+f x)+b \sin (e+f x)) \left (-2 i (e+f x) \left (a^2 c d+a b \left (d^2-c^2\right )-b^2 c d\right ) (a \cos (e+f x)+b \sin (e+f x))-\left (a^2 c d+a b \left (d^2-c^2\right )-b^2 c d\right ) (a \cos (e+f x)+b \sin (e+f x)) \log \left ((a \cos (e+f x)+b \sin (e+f x))^2\right )+2 i \left (a^2 c d+a b \left (d^2-c^2\right )-b^2 c d\right ) \tan ^{-1}(\tan (e+f x)) (a \cos (e+f x)+b \sin (e+f x))+\frac{\left (a^2+b^2\right ) (b c-a d)^2 \sin (e+f x)}{a}+(e+f x) (a (c+d)+b (d-c)) (a (c-d)+b (c+d)) (a \cos (e+f x)+b \sin (e+f x))\right )}{f \left (a^2+b^2\right )^2 (a+b \tan (e+f x))^2 (c \cos (e+f x)+d \sin (e+f x))^2} \]

Antiderivative was successfully verified.

[In]

Integrate[(c + d*Tan[e + f*x])^2/(a + b*Tan[e + f*x])^2,x]

[Out]

((a*Cos[e + f*x] + b*Sin[e + f*x])*(((a^2 + b^2)*(b*c - a*d)^2*Sin[e + f*x])/a + (b*(-c + d) + a*(c + d))*(a*(
c - d) + b*(c + d))*(e + f*x)*(a*Cos[e + f*x] + b*Sin[e + f*x]) - (2*I)*(a^2*c*d - b^2*c*d + a*b*(-c^2 + d^2))
*(e + f*x)*(a*Cos[e + f*x] + b*Sin[e + f*x]) + (2*I)*(a^2*c*d - b^2*c*d + a*b*(-c^2 + d^2))*ArcTan[Tan[e + f*x
]]*(a*Cos[e + f*x] + b*Sin[e + f*x]) - (a^2*c*d - b^2*c*d + a*b*(-c^2 + d^2))*Log[(a*Cos[e + f*x] + b*Sin[e +
f*x])^2]*(a*Cos[e + f*x] + b*Sin[e + f*x]))*(c + d*Tan[e + f*x])^2)/((a^2 + b^2)^2*f*(c*Cos[e + f*x] + d*Sin[e
 + f*x])^2*(a + b*Tan[e + f*x])^2)

________________________________________________________________________________________

Maple [B]  time = 0.032, size = 465, normalized size = 3.7 \begin{align*}{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ){a}^{2}cd}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) ab{c}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) ab{d}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ){b}^{2}cd}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{\arctan \left ( \tan \left ( fx+e \right ) \right ){a}^{2}{c}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{\arctan \left ( \tan \left ( fx+e \right ) \right ){a}^{2}{d}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+4\,{\frac{\arctan \left ( \tan \left ( fx+e \right ) \right ) abcd}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{\arctan \left ( \tan \left ( fx+e \right ) \right ){b}^{2}{c}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{\arctan \left ( \tan \left ( fx+e \right ) \right ){b}^{2}{d}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{{a}^{2}{d}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) b \left ( a+b\tan \left ( fx+e \right ) \right ) }}+2\,{\frac{acd}{f \left ({a}^{2}+{b}^{2} \right ) \left ( a+b\tan \left ( fx+e \right ) \right ) }}-{\frac{b{c}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) \left ( a+b\tan \left ( fx+e \right ) \right ) }}-2\,{\frac{\ln \left ( a+b\tan \left ( fx+e \right ) \right ){a}^{2}cd}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+2\,{\frac{\ln \left ( a+b\tan \left ( fx+e \right ) \right ) ab{c}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-2\,{\frac{\ln \left ( a+b\tan \left ( fx+e \right ) \right ) ab{d}^{2}}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+2\,{\frac{\ln \left ( a+b\tan \left ( fx+e \right ) \right ){b}^{2}cd}{f \left ({a}^{2}+{b}^{2} \right ) ^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((c+d*tan(f*x+e))^2/(a+b*tan(f*x+e))^2,x)

[Out]

1/f/(a^2+b^2)^2*ln(1+tan(f*x+e)^2)*a^2*c*d-1/f/(a^2+b^2)^2*ln(1+tan(f*x+e)^2)*a*b*c^2+1/f/(a^2+b^2)^2*ln(1+tan
(f*x+e)^2)*a*b*d^2-1/f/(a^2+b^2)^2*ln(1+tan(f*x+e)^2)*b^2*c*d+1/f/(a^2+b^2)^2*arctan(tan(f*x+e))*a^2*c^2-1/f/(
a^2+b^2)^2*arctan(tan(f*x+e))*a^2*d^2+4/f/(a^2+b^2)^2*arctan(tan(f*x+e))*a*b*c*d-1/f/(a^2+b^2)^2*arctan(tan(f*
x+e))*b^2*c^2+1/f/(a^2+b^2)^2*arctan(tan(f*x+e))*b^2*d^2-1/f/(a^2+b^2)/b/(a+b*tan(f*x+e))*a^2*d^2+2/f/(a^2+b^2
)/(a+b*tan(f*x+e))*a*c*d-1/f/(a^2+b^2)*b/(a+b*tan(f*x+e))*c^2-2/f/(a^2+b^2)^2*ln(a+b*tan(f*x+e))*a^2*c*d+2/f/(
a^2+b^2)^2*ln(a+b*tan(f*x+e))*a*b*c^2-2/f/(a^2+b^2)^2*ln(a+b*tan(f*x+e))*a*b*d^2+2/f/(a^2+b^2)^2*ln(a+b*tan(f*
x+e))*b^2*c*d

________________________________________________________________________________________

Maxima [A]  time = 1.59817, size = 311, normalized size = 2.47 \begin{align*} \frac{\frac{{\left (4 \, a b c d +{\left (a^{2} - b^{2}\right )} c^{2} -{\left (a^{2} - b^{2}\right )} d^{2}\right )}{\left (f x + e\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{2 \,{\left (a b c^{2} - a b d^{2} -{\left (a^{2} - b^{2}\right )} c d\right )} \log \left (b \tan \left (f x + e\right ) + a\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{{\left (a b c^{2} - a b d^{2} -{\left (a^{2} - b^{2}\right )} c d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}}{a^{3} b + a b^{3} +{\left (a^{2} b^{2} + b^{4}\right )} \tan \left (f x + e\right )}}{f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c+d*tan(f*x+e))^2/(a+b*tan(f*x+e))^2,x, algorithm="maxima")

[Out]

((4*a*b*c*d + (a^2 - b^2)*c^2 - (a^2 - b^2)*d^2)*(f*x + e)/(a^4 + 2*a^2*b^2 + b^4) + 2*(a*b*c^2 - a*b*d^2 - (a
^2 - b^2)*c*d)*log(b*tan(f*x + e) + a)/(a^4 + 2*a^2*b^2 + b^4) - (a*b*c^2 - a*b*d^2 - (a^2 - b^2)*c*d)*log(tan
(f*x + e)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) - (b^2*c^2 - 2*a*b*c*d + a^2*d^2)/(a^3*b + a*b^3 + (a^2*b^2 + b^4)*ta
n(f*x + e)))/f

________________________________________________________________________________________

Fricas [B]  time = 1.5251, size = 622, normalized size = 4.94 \begin{align*} -\frac{b^{3} c^{2} - 2 \, a b^{2} c d + a^{2} b d^{2} -{\left (4 \, a^{2} b c d +{\left (a^{3} - a b^{2}\right )} c^{2} -{\left (a^{3} - a b^{2}\right )} d^{2}\right )} f x -{\left (a^{2} b c^{2} - a^{2} b d^{2} -{\left (a^{3} - a b^{2}\right )} c d +{\left (a b^{2} c^{2} - a b^{2} d^{2} -{\left (a^{2} b - b^{3}\right )} c d\right )} \tan \left (f x + e\right )\right )} \log \left (\frac{b^{2} \tan \left (f x + e\right )^{2} + 2 \, a b \tan \left (f x + e\right ) + a^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) -{\left (a b^{2} c^{2} - 2 \, a^{2} b c d + a^{3} d^{2} +{\left (4 \, a b^{2} c d +{\left (a^{2} b - b^{3}\right )} c^{2} -{\left (a^{2} b - b^{3}\right )} d^{2}\right )} f x\right )} \tan \left (f x + e\right )}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} f \tan \left (f x + e\right ) +{\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c+d*tan(f*x+e))^2/(a+b*tan(f*x+e))^2,x, algorithm="fricas")

[Out]

-(b^3*c^2 - 2*a*b^2*c*d + a^2*b*d^2 - (4*a^2*b*c*d + (a^3 - a*b^2)*c^2 - (a^3 - a*b^2)*d^2)*f*x - (a^2*b*c^2 -
 a^2*b*d^2 - (a^3 - a*b^2)*c*d + (a*b^2*c^2 - a*b^2*d^2 - (a^2*b - b^3)*c*d)*tan(f*x + e))*log((b^2*tan(f*x +
e)^2 + 2*a*b*tan(f*x + e) + a^2)/(tan(f*x + e)^2 + 1)) - (a*b^2*c^2 - 2*a^2*b*c*d + a^3*d^2 + (4*a*b^2*c*d + (
a^2*b - b^3)*c^2 - (a^2*b - b^3)*d^2)*f*x)*tan(f*x + e))/((a^4*b + 2*a^2*b^3 + b^5)*f*tan(f*x + e) + (a^5 + 2*
a^3*b^2 + a*b^4)*f)

________________________________________________________________________________________

Sympy [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c+d*tan(f*x+e))**2/(a+b*tan(f*x+e))**2,x)

[Out]

Exception raised: AttributeError

________________________________________________________________________________________

Giac [B]  time = 1.51436, size = 448, normalized size = 3.56 \begin{align*} \frac{\frac{{\left (a^{2} c^{2} - b^{2} c^{2} + 4 \, a b c d - a^{2} d^{2} + b^{2} d^{2}\right )}{\left (f x + e\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{{\left (a b c^{2} - a^{2} c d + b^{2} c d - a b d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{2 \,{\left (a b^{2} c^{2} - a^{2} b c d + b^{3} c d - a b^{2} d^{2}\right )} \log \left ({\left | b \tan \left (f x + e\right ) + a \right |}\right )}{a^{4} b + 2 \, a^{2} b^{3} + b^{5}} - \frac{2 \, a b^{3} c^{2} \tan \left (f x + e\right ) - 2 \, a^{2} b^{2} c d \tan \left (f x + e\right ) + 2 \, b^{4} c d \tan \left (f x + e\right ) - 2 \, a b^{3} d^{2} \tan \left (f x + e\right ) + 3 \, a^{2} b^{2} c^{2} + b^{4} c^{2} - 4 \, a^{3} b c d + a^{4} d^{2} - a^{2} b^{2} d^{2}}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )}{\left (b \tan \left (f x + e\right ) + a\right )}}}{f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c+d*tan(f*x+e))^2/(a+b*tan(f*x+e))^2,x, algorithm="giac")

[Out]

((a^2*c^2 - b^2*c^2 + 4*a*b*c*d - a^2*d^2 + b^2*d^2)*(f*x + e)/(a^4 + 2*a^2*b^2 + b^4) - (a*b*c^2 - a^2*c*d +
b^2*c*d - a*b*d^2)*log(tan(f*x + e)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) + 2*(a*b^2*c^2 - a^2*b*c*d + b^3*c*d - a*b^
2*d^2)*log(abs(b*tan(f*x + e) + a))/(a^4*b + 2*a^2*b^3 + b^5) - (2*a*b^3*c^2*tan(f*x + e) - 2*a^2*b^2*c*d*tan(
f*x + e) + 2*b^4*c*d*tan(f*x + e) - 2*a*b^3*d^2*tan(f*x + e) + 3*a^2*b^2*c^2 + b^4*c^2 - 4*a^3*b*c*d + a^4*d^2
 - a^2*b^2*d^2)/((a^4*b + 2*a^2*b^3 + b^5)*(b*tan(f*x + e) + a)))/f